// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 退出登录接口 POST /api/sysUser/loginOut */
export async function outLogin(options?: { [key: string]: any }) {
  const token = window.localStorage.getItem("token");
  const username = window.localStorage.getItem("username");
  window.localStorage.removeItem("token");
  window.localStorage.removeItem("username");
  console.log("退出登录接口 POST /api/sysUser/loginOut",options);
  return request<Record<string, any>>('/api/sysUser/loginOut', {
    method: 'POST',
    params: {
      token: token,
      username: username,
    },
  });
}


/** 登录接口 POST /api/user/login */
export async function login(body: UserAPI.LoginParams) {
    console.log(body.username);
    return request<UserAPI.LoginResult>('/api/user/login', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
      },
      params: {username: body.username, password: body.password},
    });
  }
/** 获取当前的用户 GET /api/sysUser/currentUser */
export async function currentUser(options?: { [key: string]: any }) {
  console.log("获取当前的用户",options);
  return request<{
    data: UserAPI.CurrentUser;
  }>('/api/sysUser/getCurrentUser', {
    method: 'GET',
    params: {
      token: options?.token,
      username: options?.username,
    },
  });
}